﻿using UnityEngine;

public class PsActionDestruct : MonoBehaviour
{
    public float m_fLifeTime = 0.0f;
    public bool m_bDestory = true;
    SmartTimer m_stLife = new SmartTimer();
    PsActionDestruct()
    {

    }
    public void OnEnable()
    {
        if (m_fLifeTime == 0)
            TrigAction();
        else
            m_stLife.DoReset(m_fLifeTime);
    }
    public bool TrigAction()
    {
        if (m_bDestory)
            gameObject.StopOrDestroy();
        else
            gameObject.SetActive(false);
        return true;
    }

    private void Update()
    {
        if (m_stLife.DoUpdate())
            TrigAction();
    }
}